package com.ittony.controller.user;

import com.ittony.constant.StatusConstant;
import com.ittony.entity.SetMeal;
import com.ittony.result.Result;
import com.ittony.service.SetMealService;
import com.ittony.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/setmeal")
@Slf4j
@Api(tags = "")
public class SetMealController {

    @Autowired
    private SetMealService setMealService;

    @RequestMapping("/list")
    @ApiOperation("")
    public Result<List<SetMeal>> list(@RequestParam Long categoryId) {
        SetMeal setMeal = new SetMeal();
        setMeal.setCategoryId(categoryId);
        setMeal.setStatus(StatusConstant.ENABLE);

        List<SetMeal> setMealList = setMealService.listByCategoryId(setMeal);

        return Result.success(setMealList);

    }

    @GetMapping("/dish/{id}")
    @ApiOperation("")
    public Result<List<DishItemVO>> dishList(@PathVariable("id") Long id) {

        List<DishItemVO>  list = setMealService.getDishItemById(id);

        return Result.success(list);
    }

}
